<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>驰骋BPM</title>
  <script type="text/javascript" src="../CCMobile/Scripts/bootstrap/js/jquery.min.js"></script>
  <script src="../CCMobile/Scripts/QueryString.js" type="text/javascript"></script>
  <script src="../CCMobile/Scripts/config.js" type="text/javascript"></script>
  <script src="../CCMobile/Comm/Gener.js" type="text/javascript"></script>
  <script src="https://g.alicdn.com/dingding/dingtalk-jsapi/2.10.3/dingtalk.open.js"></script>
  <script type="text/javascript">
    dd.ready(function() {
      //获取钉钉企业ID
      var dingHandler=new HttpHandler("bp.difference.handler.CCMobileHandler");
      var ding_corpid=dingHandler.DoMethodReturnString("getDingCorpID");
      if(ding_corpid!=""||ding_corpid!=null||ding_corpid!=undefined){
        //获取个人信息
        dd.runtime.permission.requestAuthCode({
          corpId: ding_corpid, // 企业id
          onSuccess: function(info) {
            var randomCode =info.code;
            var handler=new HttpHandler("bp.difference.handler.CCMobileHandler");
            handler.AddPara("rcode",randomCode);
            var data=handler.DoMethodReturnString("getDingTalkUserInfo");
            if(data.indexOf('err@') ==0) {
              alert("登录验证错误，错误的帐号："+randomCode);
              location.reload();
              return;
            }
            else {
              var json=JSON.parse(data);
              var url='../CCMobile/Home.htm?Token='+json.token;
              window.location.href = url;
            }
          },
          onFail:function (err) {
            alert(JSON.stringify(err));
          }
        });
      }
    });

    function IsPC() {
      var userAgentInfo = navigator.userAgent;
      var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
      var flag = true;
      for (var v = 0; v < Agents.length; v++) {
        if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }
      }
      return flag;
    }
  </script>
</head>

<body>
</body>
</html>
